<template>
  <div>
    <Searchbar>
      <el-input @change="getList" v-model="search.order_no" placeholder="请输入订单号"></el-input>
      <el-input @change="getList" v-model="search.real_name" placeholder="请输入用户名"></el-input>
      <el-input @change="getList" v-model="search.keyword" placeholder="请输入课程、实验、考试名"></el-input>
      <el-button class="search-btn" @click="getList" type="primary">查询</el-button>
    </Searchbar>

    <el-table :data="tableData" style="width: 100%">
      <el-table-column prop="order_no" label="订单号" ></el-table-column>
      <el-table-column prop="user_name" label="用户名" ></el-table-column>
      <el-table-column prop="order_type_label" label="订单类型" ></el-table-column>
      <el-table-column prop="body" label="订单详情" ></el-table-column>
      <el-table-column label="订单状态" >
        <template slot-scope="scope">
          <span :class="scope.row.status == 1 ? 'text-success' : 'text-warning'">{{scope.row.status_label}}</span>
        </template>
      </el-table-column>
      <el-table-column label="金额" >
        <template slot-scope="scope">
          <span class="price">￥{{scope.row.total_fee/100}} 元</span>
        </template>
      </el-table-column>
      <el-table-column prop="create_time" label="下单时间" ></el-table-column>
    </el-table>
    <el-pagination
      background
      layout="prev, pager, next, jumper"
      @current-change="handleCurrentChange"
      @size-change=handleSizeChange
      :current-page.sync="search.page"
      :page-size="search.page_size"
      :total="total"
    ></el-pagination>
  </div>
</template>
<script>
import pageMixin from "@/mixins/pageMixin";
import { orderModel } from "@/api/admin_models";
import Searchbar from "@/components/Searchbar";
export default {
  mixins: [pageMixin],
  components: {Searchbar},
  data() {
    return {
      tableData: [],
      total: 0,
      search: {
        school_name: null,
        page: 1
      }
    };
  },
  mounted() {
    this.getList();
  },
  methods: {
    getList() {
      console.log("getList");
      orderModel.list(
        this.search,
        res => {
          this.total = res.total_records;
          this.tableData = res.data.map(v => {
            return v;
          });
        },
        err => {
          console.log(err);
        }
      );
    }
  }
};
</script>
<style lang="scss">
</style>